package com.xydtech.ecard.ftp.service.impl;

import com.xydtech.common.core.domain.entity.SysDept;
import com.xydtech.common.utils.ShiroUtils;
import com.xydtech.ecard.ftp.domain.FtpDepositLoanAdjustmentConfig;
import com.xydtech.ecard.ftp.mapper.FtpDepositLoanAdjustmentConfigMapper;
import com.xydtech.ecard.ftp.service.IFtpDepositLoanAdjustmentConfigService;
import com.xydtech.system.service.ISysDeptService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: liliya
 * @Description: FTP内生性调整型参数配置表ftp_deposit_loan_adjustment_config
 * @Date: Created in 2023/8/16 16:32
 * @Modified:
 */
@Service
public class FtpDepositLoanAdjustmentConfigServiceImpl implements IFtpDepositLoanAdjustmentConfigService {

    @Autowired
    private FtpDepositLoanAdjustmentConfigMapper ftpDepositLoanAdjustmentConfigMapper;
    @Autowired
    private ISysDeptService sysDeptService;

    /**
     * 查询全表基础数据
     * @return
     */
    @Override
    public List<FtpDepositLoanAdjustmentConfig> selectBaseList(FtpDepositLoanAdjustmentConfig config){
        return ftpDepositLoanAdjustmentConfigMapper.selectBaseList();
    }

    /**
     * 通过期限匹配法-期限流动性溢价调整项:定价期限(天数上限,闭区间)和config_key查对应区间
     *
     * @param dictValue sys_dict_data   12
     * @param dictType  sys_dict_data   repricing_frequency_type
     * @param unit      ftp_deposit_loan_adjustment_config  单位Y年
     * @param calcuDay  ftp_deposit_loan_adjustment_config的calcu_under_day与calcu_upper_day差值
     * @return
     */
    @Override
    public FtpDepositLoanAdjustmentConfig selectBaseListOfSysRelationUpperClose(String dictValue,
                                                                                String dictType,
                                                                                String unit,
                                                                                Integer calcuDay) {
        SysDept sysDept = sysDeptService.selectSecondLevelDeptByDeptId(ShiroUtils.getSysUser().getDeptId());
        return ftpDepositLoanAdjustmentConfigMapper.selectBaseListOfSysRelationUpperClose(dictValue, dictType, unit, calcuDay, sysDept.getDeptId());
    }




    @Override
    public FtpDepositLoanAdjustmentConfig selectBaseListOfSysRelationInfo(@Param("dictValue") String dictValue,
                                                                   @Param("dictType") String dictType,
                                                                   @Param("unit") String unit,
                                                                   @Param("originalDeadlineType") String originalDeadlineType) {
        SysDept sysDept = sysDeptService.selectSecondLevelDeptByDeptId(ShiroUtils.getSysUser().getDeptId());
        return ftpDepositLoanAdjustmentConfigMapper.selectBaseListOfSysRelationInfo(dictValue, dictType, unit, originalDeadlineType, sysDept.getDeptId());
    }


    /**
     * 通过期限匹配法-结息频率调整项:定价期限(天数上限,闭区间)和config_key查对应区间
     *
     * @param dictValue sys_dict_data   1/3
     * @param dictType  sys_dict_data   repricing_frequency_type
     * @param unit      ftp_deposit_loan_adjustment_config  单位Y年
     * @param calcuDay  ftp_deposit_loan_adjustment_config的calcu_under_day与calcu_upper_day差值
     * @return
     */
    @Override
    public FtpDepositLoanAdjustmentConfig selectBaseListOfSysRelationUnderClose(String dictValue,
                                                                                String dictType,
                                                                                String unit,
                                                                                Integer calcuDay) {
        SysDept sysDept = sysDeptService.selectSecondLevelDeptByDeptId(ShiroUtils.getSysUser().getDeptId());
        return ftpDepositLoanAdjustmentConfigMapper.selectBaseListOfSysRelationUnderClose(dictValue, dictType, unit, calcuDay, sysDept.getDeptId());
    }



    /**
     * 查询
     */
    @Override
    public FtpDepositLoanAdjustmentConfig selectBaseById(Integer id) {
        return ftpDepositLoanAdjustmentConfigMapper.selectBaseById(id);
    }

    /**
     * 新增
     */
    @Override
    public int insertBase(FtpDepositLoanAdjustmentConfig config) {
        return ftpDepositLoanAdjustmentConfigMapper.insertBase(config);
    }

    /**
     * 修改
     */
    @Override
    public int updateBase(FtpDepositLoanAdjustmentConfig config) {
        return ftpDepositLoanAdjustmentConfigMapper.updateBase(config);
    }

    /**
     * 删除
     */
    @Override
    public int deleteBaseById(Long configId) {
        return ftpDepositLoanAdjustmentConfigMapper.deleteBaseById(configId);
    }

    /**
     * 批量删除
     */
    @Override
    public int deleteBaseByIds(Long[] configIds) {
        return ftpDepositLoanAdjustmentConfigMapper.deleteBaseByIds(configIds);
    }


}